#pragma once
#include "Connection.h"

class CGateClient;
class CGateServer : public CConnection
{
protected:
	virtual void RegisteMessage();
	virtual xgc_lpvoid OnAccept( net::network_t h, xgc_long_ptr from );
	virtual void OnClose( xgc_lpvoid userdata );

public:
	void StartServer( xgc_lpcstr address, xgc_uint16 port, xgc_uint16 test_invent, xgc_uint16 timeout );
	void StopServer();

protected:
	xgc_void ProcessLogin( net::network_t h, xgc_lpvoid u, const xgc_byte* data, xgc_size size );
	xgc_void ProcessGameRelay( net::network_t h, xgc_lpvoid u, const xgc_byte* data, xgc_size size );
	xgc_void ProcessGateSessionCheckRpn( net::network_t h, xgc_lpvoid u, const xgc_byte* data, xgc_size size );
private:
	xgc_long_ptr mServer;

	typedef std::map< xgc_uint32, CGateClient* > GateClientMap;
	typedef std::list< CGateClient* > FreeClientList;

	FreeClientList lstFreeClient;
};